
#include "texture_mgr.h"
#include "string.h"

TextureMgr::TextureMgr()
{

}

TextureMgr::~TextureMgr()
{
}

void TextureMgr::SetRextureResourceDirectory(char *dir)
{
	textureResourceDirectory = new char[strlen(dir) + 1];
	strcpy(textureResourceDirectory,dir);
}


Texture *TextureMgr::GetTexture(char *textureName)
{
	for(int i = 0; i < textureArray.size(); i ++)
	{
		if(!strcmp(textureName,textureArray[i]->textureName))
			return textureArray[i];
	}

	Texture *texture = LoadTexture(textureName);
	if(texture != NULL)
	{
		textureArray.push_back(texture);
	}

	return texture;
}

//texture class

Texture::Texture(char *name)
{
	textureName = new char[strlen(name)+1];
	strcpy(textureName,name);
}

Texture::~Texture()
{
	if(textureName != NULL)
		delete textureName;
	textureName = NULL;
}


